package com.connectlinkcorp.common.ui.demo;

import java.util.ArrayList;
import com.connectlinkcorp.common.ui.numbertiles.NumberTile;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient.CustomViewCallback;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;
import android.app.Activity;
import android.content.Context;


/*
 *  Number view UI is extend LinearLayout and contant a gridview. 
 *  To use it, as normal UI View (like textview, button...). 
 *  use method setUpParam to add config like: number of row, colum...
 *  set adapter to it (I add this for other developer easy config item in it)
 *  use method show to make it visible on screen
 */



public class MainActivity extends Activity {
	int imageDigit[] = new int[]{
		R.drawable.digit00,R.drawable.digit01,R.drawable.digit02,R.drawable.digit03,R.drawable.digit04,
		R.drawable.digit05,R.drawable.digit06,R.drawable.digit07,R.drawable.digit08,R.drawable.digit09,
		R.drawable.digit10,R.drawable.digit11,R.drawable.digit12,R.drawable.digit13,R.drawable.digit14,
		R.drawable.digit15,R.drawable.digit16,R.drawable.digit17,R.drawable.digit18,R.drawable.digit19,
		R.drawable.digit20,R.drawable.digit21,R.drawable.digit22,R.drawable.digit23,R.drawable.digit24,
		R.drawable.digit25,R.drawable.digit26,R.drawable.digit27,R.drawable.digit28,R.drawable.digit29,
		R.drawable.digit30,R.drawable.digit31,R.drawable.digit32,R.drawable.digit33,R.drawable.digit34,
		R.drawable.digit35,R.drawable.digit36,R.drawable.digit37,R.drawable.digit38,R.drawable.digit39,
		R.drawable.digit40,R.drawable.digit41,R.drawable.digit42,R.drawable.digit43,R.drawable.digit44,
		R.drawable.digit45,R.drawable.digit46,R.drawable.digit47,R.drawable.digit48,R.drawable.digit49,
		R.drawable.digit50,R.drawable.digit51,R.drawable.digit52,R.drawable.digit53,R.drawable.digit54,
		R.drawable.digit55,R.drawable.digit56,R.drawable.digit57,R.drawable.digit58,R.drawable.digit59,
		R.drawable.digit60,R.drawable.digit61,R.drawable.digit62,R.drawable.digit63,R.drawable.digit64,
		R.drawable.digit65,R.drawable.digit66,R.drawable.digit67,R.drawable.digit68,R.drawable.digit69,
		R.drawable.digit70,R.drawable.digit71,R.drawable.digit72,R.drawable.digit73,R.drawable.digit74,
		R.drawable.digit75,R.drawable.digit76,R.drawable.digit77,R.drawable.digit78,R.drawable.digit79,
		R.drawable.digit80,R.drawable.digit81,R.drawable.digit82,R.drawable.digit83,R.drawable.digit84,
		R.drawable.digit85,R.drawable.digit86,R.drawable.digit87,R.drawable.digit88,R.drawable.digit89,
		R.drawable.digit90,R.drawable.digit91,R.drawable.digit92,R.drawable.digit93,R.drawable.digit94,
		R.drawable.digit95,R.drawable.digit96,R.drawable.digit97,R.drawable.digit98,R.drawable.digit99};
	NumberTile numberView;
	ArrayList<Integer> numbers;
	
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		int [] numbersArr = new int []{1, 2, 12 ,2, 2, 12};
		numbers = new ArrayList<Integer>();
		for (int i = 0; i < numbersArr.length; i++) {
			numbers.add(numbersArr[i]);
		}
		numberView = (NumberTile)findViewById(R.id.numberTileView);
		
		// set up param
		numberView.setUpParam(2, 3, 200, 100, 200, 150, numbers, this);
		
		// set resource background for digit
		numberView.setImageDigit(imageDigit);
		
		// set id row layout for adapter
		numberView.setRowLayoutId(R.layout.row_numbertile);
		
		// show number
		numberView.show();
		
		// set up Item Clicked
		numberView.setOnItemClicked(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int position,
					long arg3) {
				// TODO Auto-generated method stub
				Toast.makeText(MainActivity.this, "Number clicked is" + String.valueOf(numberView.getNumbers().get(position)), Toast.LENGTH_SHORT).show();
			}
		});
		
	}

}
